home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / answers / motif-faq / part5 < prev    next >
Encoding:
Text File  |  1993-06-30  |  59.2 KB  |  1,654 lines

  1. Newsgroups: comp.windows.x.motif,news.answers,comp.answers
  2. Path: senator-bedfellow.mit.edu!enterpoop.mit.edu!spool.mu.edu!sdd.hp.com!caen!batcomputer!munnari.oz.au!newshost.anu.edu.au!csc.canberra.edu.au!news
  3. From: jan@ise.canberra.edu.au (Jan Newmarch)
  4. Subject: Motif FAQ (Part 5 of 5)
  5. Message-ID: <1993Jul1.011220.28088@csc.canberra.edu.au>
  6. Followup-To: comp.windows.x.motif
  7. Keywords: FAQ question answer
  8. Sender: news@csc.canberra.edu.au
  9. Reply-To: jan@ise.canberra.edu.au (Jan Newmarch)
  10. Organization: University of Canberra
  11. Date: Thu, 1 Jul 93 01:12:20 GMT
  12. Approved: news-answers-request@MIT.Edu
  13. Expires: +1 months
  14. Lines: 1637
  15. Xref: senator-bedfellow.mit.edu comp.windows.x.motif:18410 news.answers:9859 comp.answers:1164
  16.  
  17. Archive-name: motif-faq/part5
  18. Last-modified: Wed July 1 1993
  19. Version: 3.6
  20.  
  21.  
  22.  
  23.  
  24.  
  25. -----------------------------------------------------------------------------
  26. Subject: 120) TOPIC: ICONS
  27.  
  28. Iconification/de-iconification is a co-operative process between a client and
  29. a window manager.  The relevant standards are set by ICCCM.  Mwm is ICCCM
  30. compliant.  The toplevel (non-override-redirect) windows of an application may
  31. be in three states: WithdrawnState (neither the window nor icon visible),
  32. NormalState (the window visible) or IconicState (the icon window or pixmap
  33. visible).  This information is contained in the WM_STATE property but ordinary
  34. clients are not supposed to look at that (its values have not yet been
  35. standardised).  Movement between the three states is standardised by ICCCM.
  36.  
  37. -----------------------------------------------------------------------------
  38. Subject: 121) How can I keep track of changes to iconic/normal window state?
  39.  
  40. Answer: You can look at the WM_STATE property, but this breaks ICCCM
  41. guidelines.  ICCCM compliant window managers will map windows in changing them
  42. to normal state and unmap them in changing them to iconic state. Look for
  43. StructureNotify events and check the event type:
  44.  
  45.         XtAddEventHandler (toplevel_widget,
  46.                         StructureNotifyMask,
  47.                         False,
  48.                         StateWatcher,
  49.                         (Opaque) NULL);
  50.         ....
  51.         void StateWatcher (w, unused, event)
  52.         Widget w;
  53.         caddr_t unused;
  54.         XEvent *event;
  55.         {
  56.                 if (event->type == MapNotify)
  57.                         printf ("normal\n");
  58.                 else if (event->type == UnmapNotify)
  59.                         printf ("iconified\n");
  60.                 else    printf ("other event\n");
  61.         }
  62.  
  63.  
  64. If you insist on looking at WM_STATE, here is some code (from Ken Sall) to do
  65. it:
  66.  
  67.         /*
  68.         ------------------------------------------------------------------
  69.         Try a function such as CheckWinMgrState below which returns one of
  70.         IconicState | NormalState | WithdrawnState | NULL :
  71.         ------------------------------------------------------------------
  72.         */
  73.         #define WM_STATE_ELEMENTS 1
  74.  
  75.         unsigned long *CheckWinMgrState (dpy, window)
  76.         Display *dpy;
  77.         Window window;
  78.         {
  79.           unsigned long *property = NULL;
  80.           unsigned long nitems;
  81.           unsigned long leftover;
  82.           Atom xa_WM_STATE, actual_type;
  83.           int actual_format;
  84.           int status;
  85.  
  86.             xa_WM_STATE = XInternAtom (dpy, "WM_STATE", False);
  87.  
  88.             status = XGetWindowProperty (dpy, window,
  89.                           xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
  90.                           False, xa_WM_STATE, &actual_type, &actual_format,
  91.                           &nitems, &leftover, (unsigned char **)&property);
  92.  
  93.             if ( ! ((status == Success) &&
  94.                         (actual_type == xa_WM_STATE) &&
  95.                         (nitems == WM_STATE_ELEMENTS)))
  96.                 {
  97.                 if (property)
  98.                     {
  99.                     XFree ((char *)property);
  100.                     property = NULL;
  101.                     }
  102.                 }
  103.             return (property);
  104.         } /* end CheckWinMgrState */
  105.  
  106.  
  107. -----------------------------------------------------------------------------
  108. Subject: 122) How can I check if my application has come up iconic?  I want to
  109. delay initialisation code and other processing.
  110.  
  111. Answer: Use XtGetValues and check for the XmNinitialState value of the
  112. toplevel shell just before XtMainLoop. -- IconicState is iconic, NormalState
  113. is not iconic.
  114.  
  115.  
  116.  
  117.  
  118. -----------------------------------------------------------------------------
  119. Subject: 123) How can I start my application in iconic state?
  120.  
  121. Answer: From the command line
  122.  
  123.         application -iconic
  124.  
  125. Using the resource mechanism, set the resource XmNinitialState to IconicState
  126. of the toplevel shell widget (the one returned from XtInitialise).
  127.  
  128. -----------------------------------------------------------------------------
  129. Subject: 124) How can an application iconify itself?
  130.  
  131. Answer: In R4 and later, use the call XIconifyWindow.
  132.  
  133. For R3, send an event to the root window with a type of WM_CHANGE_STATE and
  134. data IconicState.
  135.  
  136.         void
  137.         IconifyMe (dpy, win)
  138.         Display *dpy;
  139.         Window win;     /* toplevel window to iconify */
  140.         {
  141.                 Atom xa_WM_CHANGE_STATE;
  142.                 XClientMessageEvent ev;
  143.  
  144.                 xa_WM_CHANGE_STATE = XInternAtom (dpy,
  145.                                         "WM_CHANGE_STATE", False);
  146.  
  147.                 ev.type = ClientMessage;
  148.                 ev.display = dpy;
  149.                 ev.message_type = xa_WM_CHANGE_STATE;
  150.                 ev.format = 32;
  151.                 ev.data.l[0] = IconicState;
  152.                 ev.window = win;
  153.  
  154.                 XSendEvent (dpy,
  155.                         RootWindow (dpy, DefaultScreen(dpy)),
  156.                         True,
  157.                         (SubstructureRedirectMask | SubstructureNotifyMask),
  158.                         &ev);
  159.                 XFlush (dpy);
  160.         }
  161.  
  162.  
  163. -----------------------------------------------------------------------------
  164. Subject: 125) How can an application de-iconify itself?
  165.  
  166. Answer: XMapWindow (XtDisplay (toplevel_widget), XtWindow (toplevel_widget)).
  167.  
  168. -----------------------------------------------------------------------------
  169. Subject: 126) TOPIC: MISCELLANEOUS
  170.  
  171. -----------------------------------------------------------------------------
  172. Subject: 127)  What is the matter with Frame in Motif 1.2?
  173.  
  174. [Last modified: November 92]
  175.  
  176. Answer: This announcement has been made by OSF:
  177.  
  178. "IMPORTANT NOTICE
  179.  
  180. We have discovered two problems in the new 1.2 child alignment resources in
  181. XmFrame. Because some vendors may have committed, or are soon to commit to
  182. field releases of Motif 1.2 and 1.2.1, OSF's options for fixing them are
  183. limited. We are trying to deal with these in a way that does not cause
  184. hardship for application developers who will develop applications against
  185. various point versions of Motif. OSF's future actions for correction are
  186. summarized.
  187.  
  188. WHAT YOU SHOULD DO AND KNOW
  189.  
  190. 1. Mark the following change in your documentation.
  191.  
  192. On page 1-512 of the OSF/Motif Programmer's Reference, change the descriptions
  193. under XmNchildVerticalAlignment as follows (what follows is the CORRECT
  194. wording to match the current implementation):
  195.  
  196. XmALIGNMENT_WIDGET_TOP
  197.         Causes the BOTTOM edge of the title area to align
  198.         vertically with the top shadow of the Frame.
  199.  
  200. XmALIGNMENT_WIDGET_BOTTOM
  201.         Causes the TOP edge of the title area to align
  202.         vertically with the top shadow of the Frame.
  203.  
  204. 2. Note the following limitation on resource converters for Motif 1.2 and
  205. 1.2.1 implementations.
  206.  
  207. The rep types for XmFrame's XmNentryVerticalAlignment resource were
  208. incorrected implemented, which means that converters will not work properly.
  209. The following resource settings will not work from a resource file in 1.2 and
  210. 1.2.1:
  211.  
  212.         *childVerticalAlignment: alignment_baseline_bottom
  213.         *childVerticalAlignment: alignment_baseline_top
  214.         *childVerticalAlignment: alignment_widget_bottom
  215.         *childVerticalAlignment: alignment_widget_top
  216.  
  217. If you wish to set these values for these resources (note they are new
  218. constraint resources in XmFrame) you will have to set them directly in C or
  219. via uil.
  220.  
  221. WHAT WE WILL DO
  222.  
  223. The problem described in note #1 above will not be fixed in the OSF/Motif
  224. implementation until the next MAJOR release of Motif.  At that time we will
  225. correct the documentation and modify the code to match those new descriptions,
  226. but we will preserve the existing enumerated values and their behavior for
  227. backward compatibility for that release.
  228.  
  229. The fix for the problem described in note #2 will be shipped by OSF in Motif
  230. 1.2.2.
  231.  
  232. SUMMARY
  233.  
  234. We are sorry for any difficulty this causes Motif users.  If you have any
  235. questions or flames (I suppose I deserve it) please send them directly to me.
  236. We sincerely hope this proactive response is better for our customers than you
  237. having to figure it out yourselves!
  238.  
  239. Libby
  240.  
  241.  
  242. -----------------------------------------------------------------------------
  243. Subject: 128)  What is IMUG and how do I join it?
  244.  
  245. Answer: IMUG is the International Motif User Group founded by Quest Windows
  246. Corporation and co-sponsored by FedUNIX.  IMUG is a non-profit organization
  247. working to keep users informed on technical and standards issues, to
  248. strengthen user groups on a local level, to increase communication among users
  249. internationally, and to promote the use of an international conference as a
  250. forum for sharing and learning more about Motif.  You can join it by
  251.  
  252.  1.  Pay the annual membership fee of $20 USD directly to IMUG.  Contact
  253.  
  254.      IMUG
  255.      5200 Great America Parkway
  256.      Santa Clara,  CA  95054
  257.      (408) 496-1900
  258.      imug@quest.com
  259.  
  260.  2.  Register at the International Motif User Conference, and automatically
  261.      become an IMUG member.
  262.  
  263.  3.  Donate a pd widget, widget tool or widget builder to the IMUG Widget
  264.      Depository and receive a free one year IMUG membership.
  265.  
  266.  
  267. -----------------------------------------------------------------------------
  268. Subject: 129)  What is the X Professional Organization
  269.  
  270. [Last modified: March 93]
  271.  
  272. Answer: The X Professional Organization's (XPO) purpose is to provide service
  273. to the X community.  It will serve as an information conduit for professional
  274. users of X.  XPO will participate in X activities, and help keep its members
  275. informed on X related issues.
  276.  
  277. In addition to the communication that professional organizations offer, XPO
  278. provides these other benefits to members:
  279.  
  280.     * subscription to the The X Resource, a quarterly publication
  281.       by O'Reilly & Associates, Inc.,
  282.  
  283.     * discounts on X related products,
  284.  
  285.     * the XPO quarterly newsletter featuring:
  286.          o highlights of conference activities,
  287.          o new product information,
  288.          o articles highlighting the latest innovations in X,
  289.          o feedback from developers and users of X,
  290.          o calendar of activities,
  291.          o forum for X professionals to interact and learn,
  292.          o and much more...
  293.  
  294. Membership Information:
  295. Annual pricing information in US dollars.
  296.  
  297. Associate:  Quarterly newsletter
  298. Regular: Quarterly newsletter + subscription to The X Resource
  299. Special: Regular + The X Resource  supplemental issues
  300.  
  301. Country               Associate    Regular     Special
  302. USA                     $35.00     $100.00     $130.00
  303. Canada & Mexico         $40.00     $105.00     $140.00
  304. Europe & Africa         $45.00     $125.00     $205.00
  305. Asia & Australia        $50.00     $130.00     $215.00
  306.  
  307.  
  308. Contact:  X Professional Organization, Post Office Box 78, Beltsville,
  309. Maryland, 20704  USA
  310.  
  311. Phone/fax: (410) 799-7197, email: wbarker@wam.umd.edu
  312.  
  313.  
  314.  
  315. -----------------------------------------------------------------------------
  316. Subject: 130)  How do I set the title of a top level window?
  317.  
  318. [Last modified: September 92]
  319.  
  320. Answer: Set XmNtitle (and optionally XmNtitleEncoding) for TopLevelShells.
  321. (Note that this is of type String rather than XmStrin.) Ypu can also set
  322. XmNiconName if you want its icon to show this title.  For XmDialogShells, set
  323. the XmNdialogTitle of its immediate child, assuming it's a BulletinBoard
  324. subclass.  These can also be set in resource files.
  325.  
  326.  
  327. -----------------------------------------------------------------------------
  328. Subject: 131)  Can I use editres with Motif?
  329. [Last modified: January 93]
  330.  
  331. Answer: It isn't built in to Motif (at 1.2.0), but you can do this in your
  332. application
  333.  
  334.     extern void _XEditResCheckMessages();
  335.     ...
  336.     XtAddEventHandler(shell_widget, (EventMask)0, True,
  337.                         _XEditResCheckMessages, NULL);
  338.  
  339. once for each shell widget that you want to react to the "click to select
  340. client" protocol.  Then link your client with the R5 libXmu.
  341.  
  342. David Brooks, OSF
  343.  
  344. From Marc Quinton (quinton@stna7.stna7.stna.dgac.fr):
  345.  
  346. With X11R4 see the Editres package which is a port of the X11R5 Editres
  347. protocol and client. You can find it at :
  348.  
  349.  ftp.stna7.stna.dgac.fr(143.196.9.83):/pub/dist/Editres.tar.Z
  350.  
  351. -----------------------------------------------------------------------------
  352. Subject: 132)  How can I put decorations on transient windows using olwm?
  353.  
  354. Answer: From Jean-Philippe Martin-Flatin <syj@ecmwf.co.uk>
  355. /**********************************************************************
  356. ** WindowDecorations.c
  357. **
  358. ** Manages window decorations under the OpenLook window manager (OLWM).
  359. **
  360. ** Adapted from a C++ program posted to comp.windows.x.motif by:
  361. **
  362. **    +--------------------------------------------------------------+
  363. **    | Ron Edmark                          User Interface Group     |
  364. **    | Tel:        (408) 980-1500 x282     Integrated Systems, Inc. |
  365. **    | Internet:   edmark@isi.com          3260 Jay St.             |
  366. **    | Voice mail: (408) 980-1590 x282     Santa Clara, CA 95054    |
  367. **    +--------------------------------------------------------------+
  368. ***********************************************************************/
  369.  
  370. #include <X11/X.h>
  371. #include <X11/Xlib.h>
  372. #include <X11/Xatom.h>
  373. #include <X11/Intrinsic.h>
  374. #include <X11/StringDefs.h>
  375. #include <X11/Protocols.h>
  376. #include <Xm/Xm.h>
  377. #include <Xm/AtomMgr.h>
  378.  
  379. /*
  380. ** Decorations for OpenLook:
  381. ** The caller can OR different mask options to change the frame decoration.
  382. */
  383. #define OLWM_Header     (long)(1<<0)
  384. #define OLWM_Resize     (long)(1<<1)
  385. #define OLWM_Close      (long)(1<<2)
  386.  
  387. /*
  388. ** Prototypes
  389. */
  390. static void InstallOLWMAtoms  (Widget w);
  391. static void AddOLWMDialogFrame(Widget widget, long decorationMask);
  392.  
  393.  
  394. /*
  395. ** Global variables
  396. */
  397. static Atom AtomWinAttr;
  398. static Atom AtomWTOther;
  399. static Atom AtomDecor;
  400. static Atom AtomResize;
  401. static Atom AtomHeader;
  402. static Atom AtomClose;
  403. static int  not_installed_yet = TRUE;
  404.  
  405.  
  406. static void InstallOLWMAtoms(Widget w)
  407. {
  408.         AtomWinAttr = XInternAtom(XtDisplay(w), "_OL_WIN_ATTR" ,    FALSE);
  409.         AtomWTOther = XInternAtom(XtDisplay(w), "_OL_WT_OTHER",     FALSE);
  410.         AtomDecor   = XInternAtom(XtDisplay(w), "_OL_DECOR_ADD",    FALSE);
  411.         AtomResize  = XInternAtom(XtDisplay(w), "_OL_DECOR_RESIZE", FALSE);
  412.         AtomHeader  = XInternAtom(XtDisplay(w), "_OL_DECOR_HEADER", FALSE);
  413.         AtomClose   = XInternAtom(XtDisplay(w), "_OL_DECOR_CLOSE",  FALSE);
  414.  
  415.         not_installed_yet = FALSE;
  416. }
  417.  
  418. static void AddOLWMDialogFrame(Widget widget, long decorationMask)
  419. {
  420.         Atom   winAttrs[2];
  421.         Atom   winDecor[3];
  422.         Widget shell = widget;
  423.         Window win;
  424.         int    numberOfDecorations = 0;
  425.  
  426.         /*
  427.         ** Make sure atoms for OpenLook are installed only once
  428.         */
  429.         if (not_installed_yet) InstallOLWMAtoms(widget);
  430.  
  431.         while (!XtIsShell(shell)) shell = XtParent(shell);
  432.  
  433.         win = XtWindow(shell);
  434.  
  435.         /*
  436.         ** Tell Open Look that our window is not one of the standard OLWM window        ** types. See OLIT Widget Set Programmer's Guide pp.70-73.
  437.         */
  438.  
  439.         winAttrs[0] = AtomWTOther;
  440.  
  441.         XChangeProperty(XtDisplay(shell),
  442.                         win,
  443.                         AtomWinAttr,
  444.                         XA_ATOM,
  445.                         32,
  446.                         PropModeReplace,
  447.                         (unsigned char*)winAttrs,
  448.                         1);
  449.  
  450.         /*
  451.         ** Tell Open Look to add some decorations to our window
  452.         */
  453.         numberOfDecorations = 0;
  454.         if (decorationMask & OLWM_Header)
  455.                 winDecor[numberOfDecorations++] = AtomHeader;
  456.         if (decorationMask & OLWM_Resize)
  457.                 winDecor[numberOfDecorations++] = AtomResize;
  458.         if (decorationMask & OLWM_Close)
  459.         {
  460.                 winDecor[numberOfDecorations++] = AtomClose;
  461.  
  462.                 /*
  463.                 ** If the close button is specified, the header must be
  464.                 ** specified. If the header bit is not set, set it.
  465.                 */
  466.                 if (!(decorationMask & OLWM_Header))
  467.                         winDecor[numberOfDecorations++] = AtomHeader;
  468.         }
  469.  
  470.         XChangeProperty(XtDisplay(shell),
  471.                         win,
  472.                         AtomDecor,
  473.                         XA_ATOM,
  474.                         32,
  475.                         PropModeReplace,
  476.                         (unsigned char*)winDecor,
  477.                         numberOfDecorations);
  478. }
  479.  
  480.  
  481. /*
  482. ** Example of use of AddOLWMDialogFrame, with a bit of extra stuff
  483. */
  484. void register_dialog_to_WM(Widget shell, XtCallbackProc Cbk_func)
  485. {
  486.         Atom atom;
  487.  
  488.         /*
  489.         ** Alias the "Close" item in system menu attached to dialog shell
  490.         ** to the activate callback of "Exit" in the menubar
  491.         */
  492.         if (Cbk_func)
  493.         {
  494.             atom = XmInternAtom(XtDisplay(shell),"WM_DELETE_WINDOW",TRUE);
  495.             XmAddWMProtocolCallback(shell,atom, Cbk_func,NULL);
  496.         }
  497.  
  498.         /*
  499.         ** If Motif is the window manager, skip OpenLook specific stuff
  500.         */
  501.         if (XmIsMotifWMRunning(shell)) return;
  502.  
  503.         /*
  504.         ** Register dialog shell to OpenLook.
  505.         **
  506.         ** WARNING: on some systems, adding the "Close" button allows the title
  507.         ** to be properly centered in the title bar. On others, activating
  508.         ** "Close" crashes OpenLook. The reason is not clear yet, but it seems
  509.         ** the first case occurs with OpenWindows 2 while the second occurs with
  510.         ** Openwindows 3. Thus, comment out one of the two following lines as
  511.         ** suitable for your site, and send e-mail to syj@ecmwf.co.uk if you
  512.         ** find out what is going on !
  513.         */
  514.         AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize));
  515. /*      AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize | OLWM_Close)); */
  516. }
  517.  
  518.  
  519. -----------------------------------------------------------------------------
  520. Subject: 133) Why does an augment translation appear to act as replace for
  521. some widgets?  When I use either augment or override translations in
  522. .Xdefaults it seems to act as replace in both Motif 1.0 and 1.1
  523.  
  524. Answer: By default, the translation table is NULL.  If there is nothing
  525. specified (either in resource file, or in args), the widget's Initialize
  526. finds: Oh, there is NULL in translations, lets use our default ones.  If,
  527. however, the translations have become non-NULL, the default translations are
  528. NOT used at all. Thus, using #augment, #override or a new table has identical
  529. effect: defines the new translations. The only way you can augment/override
  530. Motif's default translations is AFTER Initialize, using XtSetValues.  Note,
  531. however, that Motif managers do play with translation tables as well ... so
  532. that results are not always easy to predict.
  533.  
  534. From OSF: A number of people have complained about not being able to
  535. augment/override translations from the .Xdefaults.  This is due to the
  536. complexity of the menu system/keyboard traversal and the necessary
  537. translations changes required to support the Motif Style Guide in menus.  It
  538. cannot be fixed in a simple way. Fixing it requires re-design of the
  539. menus/buttons and it is planned to be fixed in 1.2.
  540.  
  541.  
  542.  
  543.  
  544.  
  545. -----------------------------------------------------------------------------
  546. Subject: 134) How do you "grey" out a widget so that it cannot be activated?
  547.  
  548. Answer: Use XtSetSensitive(widget, False). Do not set the XmNsensitive
  549. resource directly yourself (by XtSetValues) since the widget may need to talk
  550. to parents first.
  551.  
  552.  
  553. -----------------------------------------------------------------------------
  554. Subject: 135) Why doesn't the Help callback work on some widgets?
  555.  
  556. Answer: If you press the help key the help callback of the widget with the
  557. keyboard focus is called (not the one containing the mouse).  You can't get
  558. the help callback of a non-keyboard-selectable widget called. To get `context
  559. sensitive' help on these, you have to find the mouse, associate its position
  560. with a widget and then do the help.
  561.  
  562.  
  563.  
  564. -----------------------------------------------------------------------------
  565. Subject: 136)  Where can I get a Table widget?
  566.  
  567. [Last modified: December 92]
  568.  
  569. Answer: Send email to Kee Hinckley (nazgul@alfalfa.com) asking for a copy of
  570. his table widget.  The Widget Creation Library also has one.  See under Motif
  571. prototyping tools for the contact.
  572.  
  573. Expert Database Systems, Inc., 377 Rector Place, Suite 3L New York, NY 10280.
  574. Phone: (212) 783-6981 has a very comprehensive table widget that uses both
  575. motif scrollbars or a "virtual" scrollbar showing a miniature version of the
  576. entire spreadsheet. Allows for different width columns, changing colors in
  577. each cell.  Only one X-Window is used so as to reduce the amount of system
  578. resources used.  Contact Ken Jones email: ken@mr_magoo.sbi.com)
  579.  
  580.  
  581. -----------------------------------------------------------------------------
  582. Subject: 137)  Has anyone done a bar graph widget?
  583. [Last modified: September 92]
  584.  
  585. Answer: You can fake one by using for each bar a scroll bar or even a label
  586. which changes in size, put inside a container of some kind.
  587.  
  588. Try the StripChart widget in the Athena widget set. Set the XtNupdate resource
  589. to 0 to keep it from automatically updating.
  590.  
  591. The comp.windows.x FAQ mentions a bar graph widget.
  592.  
  593. Expert Database Systems, Inc.  sells a bar graph widget as well as a multi-
  594. line graph with automatic scaling, a 3-D surface graph, and a high/Low graph
  595. with two lines for moving averages.  Contact Ken Jones Expert Database
  596. Systems, Inc., 377 Rector Place, Suite 3L New York, NY 10280.  Phone: (212)
  597. 783-6981
  598.  
  599.  
  600. The Xtra XWidget library contains a set of widgets that are subclassed from
  601. and compatible with either OSF/Motif or OLIT widgets.  The library includes
  602. widgets that implement the following:
  603.  
  604.    Spreadsheet
  605.    Bar Graph
  606.    Stacked Bar Graph
  607.    Line Graph
  608.    Pie Chart
  609.    XY Plot
  610.    Hypertext
  611.    Hypertext based Help System
  612.    Entry Form with type checking
  613.  
  614. Contact Graphical Software Technology at 310-328-9338  (info@gst.com) for
  615. information.
  616.  
  617. The XRT/graph widget, available for Motif, XView and OLIT, displays X-Y plots,
  618. bar and pie charts, and supports user-feedback, fast updates and PostScript
  619. output. Contact KL Group Inc. at 416-594-1026 (xrt_info%klg@uunet.ca)
  620.  
  621. The product Xmath, made by Integrated Systems Inc. is a product which has
  622. interactive 2d and 3d graphics for bar,strip,line,symbol,
  623. surface,contour,etc... that costs $2500.00 for commercial use and a mere
  624. $250.00 for university use that also has complete numerics capabilities, an
  625. easy to use debugger, a complete high level language, a spreadsheet, a motif
  626. gui access capability, and much more all created on top of motif.
  627.  
  628. You can either email to xmath-info@isi.com or call (408)980-1500.
  629.  
  630. Digital Equipment Corporation (DEC) provides the following product NetEd: "The
  631. network editor widget is a Motif toolkit conforming widget that applications
  632. can use to express complex interrelationships graphically in the form of
  633. networks or graphs. The network editor supports interactive or application-
  634. controlled creation and editing of directed graphs or networks."
  635.  
  636.  
  637. ACE/gr is an X based XY plotting tool implemented with a point 'n click
  638. paradigm.  A few of its features are:
  639.  
  640.    * Plots up to 10 graphs with 30 data sets per graph.
  641.    * Data read from files and/or pipes.
  642.    * Graph types XY, log-linear, linear-log, log-log, bar,
  643.         stacked bar charts.
  644.  
  645. it is available from
  646.  
  647.         ftp.ccalmr.ogi.edu (presently amb4.ccalmr.ogi.edu)
  648.  
  649. with IP address 129.95.72.34. The XView version (xvgr) will be found in
  650. /CCALMR/pub/acegr/xvgr-2.09.tar.Z and the Motif version (xmgr) in
  651. /CCALMR/pub/acegr/xmgr-2.09.tar.Z.  Comments, suggestions, bug reports to
  652. pturner@amb4.ccalmr.ogi.edu (if mail fails, try pturner@ese.ogi.edu). Due to
  653. time constraints, replies will be few and far between.
  654.  
  655.  
  656.  
  657. -----------------------------------------------------------------------------
  658. Subject: 138)  Does anyone know of a source code of a graph widget where you
  659. can add vertices and edges and get an automated updating?
  660.  
  661. [Last modified: March 93]
  662.  
  663. Answer: The XUG FAQ in comp.windows.x includes information on graph display
  664. widgets.  There is also an implementation in the Asente/Swick book.
  665.  
  666.   From Martin Janzen: "You could have a look at DataViews, from V.I.
  667.    Corporation.  This package is used mainly to display a variety of graph
  668.    drawings (eg. bar, line, pie, high/low, and other charts), and to update
  669.    the graphs as information is received from "data sources" such as files,
  670.    processes (through pipes), or devices.
  671.  
  672.    However, it also provides "node" and "edge" objects which can be used
  673.    when working with network graphs.  The DV-Tools function library
  674.    provides routines which traverse a graph, count visits to each node or
  675.    edge, mark nodes or edges of interest, and so on.  A node or edge object
  676.    can have an associated "geometry object" (such as a symbol or a line),
  677.    which represents that node or edge.
  678.  
  679.    Drawbacks: There's no automatic positioning algorithm; when you add a
  680.    node or edge, you have to create and position its geometry object
  681.    yourself.  Also, this isn't a set of add-on widgets; you can either have
  682.    DataViews create an X window (ie. a separate shell), or you can create
  683.    your own XmDrawingArea and use DataViews to update its window when
  684.    expose events are received.  Finally, the package is quite expensive,
  685.    and there is a run-time charge.
  686.  
  687.    The vendor's address is:
  688.      V.I. Corporation,
  689.      47 Pleasant Street,
  690.      Northampton, MA  01060,
  691.             Email: vi@vicorp.com, Phone: (413) 586-4144, Fax:   (413) 584-2649
  692.  
  693.    or
  694.  
  695.      V.I. Corporation (Europe) Ltd.,
  696.      First Base, Beacontree Plaza,
  697.      Gillette Way,                      Email: viesales@eurovi.uucp
  698.      Reading, Berkshire  RG2 0BP"
  699.    Phone: +44 734 756010,      Fax:   +44 734 756104
  700.  
  701. From Craig Timmerman: Just wanted others to know that there is a third
  702. competitor in what may be come a big market for generic APIs.  The product is
  703. called Open Interface and Neuron Data is the vendor.  Neuron has added some
  704. extra, more complex widgets to their set.  The two most notable are a table
  705. and network widget.  [...] I believe that the network widget got its name from
  706. its ability to display expert system networks that Neuron's AI tools needed.
  707. It would be more aptly named the graph widget.  It can display and manipulate
  708. graphs of various types (trees, directed graphs, etc).  Contact is
  709.  
  710.         Neuron Data
  711.         156 University Avenue
  712.         Palo Alto,  CA  94301
  713.         (415) 321-4488
  714.  
  715.  
  716. prism!gt3273b@gatech.edu  (RENALDS,ANDREW THEODORE) posted a set of public
  717. domain routines for graph drawing.  Contact him for a later set.
  718.  
  719. From Ramon Santiago (santiago@fgssu1.fgs.slb.com): HP has released source code
  720. for XmGraph and XmArc, part of the InterWorks library, which does exactly
  721. this. The sources can be obtained by contacting Dave Shaw,
  722. librarian@iworks.ecn.uiowa.edu. A few trivial source code changes need to be
  723. made to get these widgets to compile under Motif 1.2.
  724.  
  725. Free DAG - directed acyclic graph drawing software in motif environment is
  726. available. Please send a note to address below if you want it:
  727.  
  728. Budak Arpinar, TUBITAK Software Research & Development Center, Ankara,
  729. TURKIYE, E-mail : C51881@TRMETU.BITNET
  730.  
  731.  
  732.  
  733. -----------------------------------------------------------------------------
  734. Subject: 139)*  Is there a help system available, such as in Windows 3?  Or
  735. any Motif based hypertext system.
  736.  
  737. [Last modified: May 93]
  738.  
  739. Answer:
  740.  
  741. Bristol Technology have a hypertext system HyperHelp with the look-and-feel of
  742. either Motif or OpenLook. It should be available from january 31, 1992.
  743. Contact
  744.  
  745.         Bristol Technology Inc.
  746.         898 Ethan Allen Highway
  747.         Ridgefield, CT  06877
  748.         203-438-6969 (phone)
  749.         203-438-5013 (fax)
  750.         uunet.uu.net!bristol!keith
  751.  
  752. Demos are available by anonymous ftp from  ftp.uu.net (137.39.1.9) in the
  753. vendor/Bristol/HyperHelp as files sun.motif.tar.Z and hp.tar.Z.
  754.  
  755. There was a posting of a motif hypertext-widget to comp.sources.x (Author:
  756. B.Raoult ( mab@ecmwf.co.uk ) ).  It had the facility to read in helptext from
  757. a file.
  758.  
  759. From Francois Felix Ingrand (felix@idefix.laas.fr): I have translated the Info
  760. AW (originally written by Jordan Hubbard) to Motif. It is a Widget to browse
  761. Info files (format used by GNU for their various documentations). I use it as
  762. the help system of various tool I wrote.  It is available on laas.laas.fr
  763. (140.93.0.15) in /pub/prs/xinfo-motif.tar.Z
  764.  
  765. Form Scott Raney (raney@metacard.com) MetaCard is a commercial package that
  766. can be used to implement hypertext help.  The text fields support multiple
  767. typefaces, sizes, styles, colors, subscript/superscript, and hypertext links.
  768. It has a Motif interface, and a template for calling it from an Xt/Motif
  769. application is included.  You can FTP a save-disabled distribution from
  770. ftp.metacard.com or from world.std.com.  For more info, email to
  771. info@metacard.com.
  772.  
  773.  
  774. The Motifation GbR also provides a hypertext-helpsystem named 'XpgHelp'.
  775. (Motif look-and-feel / features like those known from MS Windows Help ) For a
  776. free demo or more information send email either to griebel@uni-paderborn.d e
  777. or contact the distributor:
  778.  
  779.         PEM GmbH,
  780.         Vaihinger Strasse 49,
  781.         7000 Stuttgart 80,
  782.         Germany,
  783.         +49 (0) 711 713045 (phone),
  784.         +49 (0) 711 713047 (fax),
  785.         email: basien@pem-stuttgart.de
  786.  
  787. XpgHelp has nearly the same features like HyperHelp: (multiple fonts, graphics
  788. in b&w and color, different styles, tabs, links, short links, notepad, ...)
  789.  
  790. The Interface Builder MOTIFATION uses XpgHelp as its hypertext helpsystem.
  791.  
  792.  
  793.  
  794. -----------------------------------------------------------------------------
  795. Subject: 140) Can I specify a widget in a resource file?
  796.  
  797. Answer: This answer, which uses the Xmu library, is due to David Elliott.  If
  798. the converter is added, then the name of a widget (a string) can be used in
  799. resource files, and will be converted to the appropriate widget.
  800.  
  801. This code, which was basically stolen from the Athena Form widget, adds a
  802. String to Widget converter.  I wrote it as a general routine that I call at
  803. the beginning of all of my programs, and made it so I could add other
  804. converters as needed (like String to Unit Type ;-).
  805.  
  806.         #include <X11/Intrinsic.h>
  807.         #include <X11/StringDefs.h>
  808.         #include <Xm/Xm.h>
  809.         #include <X11/Xmu/Converters.h>
  810.         #include <X11/IntrinsicP.h>
  811.         #include <X11/CoreP.h>
  812.  
  813.         void
  814.         setupConverters()
  815.         {
  816.                 static XtConvertArgRec parentCvtArgs[] = {
  817.                         {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent),
  818.                                 sizeof(Widget)}
  819.                 };
  820.  
  821.                 XtAddConverter(XmRString, XmRWindow, XmuCvtStringToWidget,
  822.                         parentCvtArgs, XtNumber(parentCvtArgs));
  823.         }
  824.  
  825.  
  826.  
  827. -----------------------------------------------------------------------------
  828. Subject: 141) Why are only some of my translations are being installed?  I
  829. have a translation table like the following, but only the first ones are
  830. getting installed and the rest are ignored.
  831.  
  832.  *Text.translations:    #override \
  833.      Ctrl<Key>a:    beginning-of-line() \n\
  834.      Ctrl<Key>e:    end-of-line() \n\
  835.      Ctrl<Key>f:    forward-character() \n\
  836.  
  837.  
  838. Answer: Most likely, you have a space at the end of one of the lines (the
  839. first in this case).
  840.  
  841.      Ctrl<Key>a:    beginning-of-line() \n\
  842.                                            ^ space here
  843.  
  844. The second backslash in each line is there to protect the real newline
  845. character and so you must not follow it with anything other than the newline
  846. itself. Otherwise it acts as the end of the resource definition and the
  847. remaining lines are not added.
  848.  
  849.  
  850. -----------------------------------------------------------------------------
  851. Subject: 142)  Where can I get the PanHandler code?
  852.  
  853. Answer: It is available by email from Chuck Ocheret:  chuck@IMSI.COM.
  854.  
  855. -----------------------------------------------------------------------------
  856. Subject: 143) What are these passive grab warnings?  When I destroy certain
  857. widgets I get a stream of messages
  858.  
  859.     Warning: Attempt to remove non-existant passive grab
  860.  
  861.  
  862. Answer: They are meaningless, and you want to ignore them.  Do this (from Kee
  863. Hinckley) by installing an XtWarning handler that explicitly looks for them
  864. and discards them:
  865.  
  866.         static void xtWarnCB(String message) {
  867.            if (asi_strstr(message, "non-existant passive grab", TRUE)) return;
  868.            ...
  869.  
  870. They come from Xt, and (W. Scott Meeks): "it's something that the designers of
  871. Xt decided the toolkit should do. Unfortunately, Motif winds up putting
  872. passive grabs all over the place for the menu system.  On the one hand, we
  873. want to remove all these grabs when menus get destroyed so that they don't
  874. leak memory; on the other hand, it's almost impossible to keep track of all
  875. the grabs, so we have a conservative strategy of ungrabbing any place where a
  876. grab could have been made and we don't explicitly know that there is no grab.
  877. The unfortunate side effect is the little passive grab warning messages.
  878. We're trying to clean these up where possible, but there are some new places
  879. where the warning is generated.  Until we get this completely cleaned up (1.2
  880. maybe), your best bet is probably to use a warning handler."
  881.  
  882. -----------------------------------------------------------------------------
  883. Subject: 144)  How do I have more buttons than three in a box?  I want to have
  884. something like a MessageBox (or other widget) with more than three buttons,
  885. but with the same nice appearance.
  886.  
  887. [Last modified: May 93]
  888.  
  889. Answer: The Motif 1.2 MessageBox widget allows extra buttons to be added after
  890. the OK button. Just create the extra buttons as children of the MessageBox.
  891. Similarly with the SelectionBox.
  892.  
  893. Pre-Motif 1.2, you have to do one of the following methods.
  894.  
  895. A SelectionBox is created with four buttons, but the fourth (the Apply button)
  896. is unmanaged. To manage it get its widget ID via
  897. XmSelectionBoxGetChild(parent, XmDIALOG_APPLY_BUTTON) and then XtManage it.
  898. Unmanage all of the other bits in the SelectionBox that you don't want.  If
  899. you want more than four buttons, try two SelectionBoxes (or similar) together
  900. in a container, where all of the unwanted parts of the widgets are unmanaged.
  901.  
  902. Alternatively, build your own dialog:
  903.  
  904. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  905.  * This program is freely distributable without licensing fees and
  906.  * is provided without guarantee or warranty expressed or implied.
  907.  * This program is -not- in the public domain.  This program is
  908.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  909.  */
  910.  
  911. /* action_area.c -- demonstrate how CreateActionArea() can be used
  912.  * in a real application.  Create what would otherwise be identified
  913.  * as a PromptDialog, only this is of our own creation.  As such,
  914.  * we provide a TextField widget for input.  When the user presses
  915.  * Return, the Ok button is activated.
  916.  */
  917. #include <Xm/DialogS.h>
  918. #include <Xm/PushBG.h>
  919. #include <Xm/PushB.h>
  920. #include <Xm/LabelG.h>
  921. #include <Xm/PanedW.h>
  922. #include <Xm/Form.h>
  923. #include <Xm/RowColumn.h>
  924. #include <Xm/TextF.h>
  925.  
  926. typedef struct {
  927.     char *label;
  928.     void (*callback)();
  929.     caddr_t data;
  930. } ActionAreaItem;
  931.  
  932. static void
  933.     do_dialog(), close_dialog(), activate_cb(),
  934.     ok_pushed(), cancel_pushed(), help();
  935.  
  936. main(argc, argv)
  937. int argc;
  938. char *argv[];
  939. {
  940.     Widget toplevel, button;
  941.     XtAppContext app;
  942.  
  943.     toplevel = XtVaAppInitialize(&app, "Demos",
  944.         NULL, 0, &argc, argv, NULL, NULL);
  945.  
  946.     button = XtVaCreateManagedWidget("Push Me",
  947.         xmPushButtonWidgetClass, toplevel, NULL);
  948.     XtAddCallback(button, XmNactivateCallback, do_dialog, NULL);
  949.  
  950.     XtRealizeWidget(toplevel);
  951.     XtAppMainLoop(app);
  952. }
  953.  
  954. /* callback routine for "Push Me" button.  Actually, this represents
  955.  * a function that could be invoked by any arbitrary callback.  Here,
  956.  * we demonstrate how one can build a standard customized dialog box.
  957.  * The control area is created here and the action area is created in
  958.  * a separate, generic routine: CreateActionArea().
  959.  */
  960. static void
  961. do_dialog(w, file)
  962. Widget w; /* will act as dialog's parent */
  963. char *file;
  964. {
  965.     Widget dialog, pane, rc, label, text_w, action_a;
  966.     XmString string;
  967.     extern Widget CreateActionArea();
  968.     Arg args[10];
  969.     static ActionAreaItem action_items[] = {
  970.         { "Ok",     ok_pushed,     NULL          },
  971.         { "Cancel", cancel_pushed, NULL          },
  972.         { "Close",  close_dialog,  NULL          },
  973.         { "Help",   help,          "Help Button" },
  974.     };
  975.  
  976.     /* The DialogShell is the Shell for this dialog.  Set it up so
  977.      * that the "Close" button in the window manager's system menu
  978.      * destroys the shell (it only unmaps it by default).
  979.      */
  980.     dialog = XtVaCreatePopupShell("dialog",
  981.         xmDialogShellWidgetClass, XtParent(w),
  982.         XmNtitle,  "Dialog Shell",     /* give arbitrary title in wm */
  983.         XmNdeleteResponse, XmDESTROY,  /* system menu "Close" action */
  984.         NULL);
  985.  
  986.     /* now that the dialog is created, set the Close button's
  987.      * client data, so close_dialog() will know what to destroy.
  988.      */
  989.     action_items[2].data = (caddr_t)dialog;
  990.  
  991.     /* Create the paned window as a child of the dialog.  This will
  992.      * contain the control area (a Form widget) and the action area
  993.      * (created by CreateActionArea() using the action_items above).
  994.      */
  995.     pane = XtVaCreateWidget("pane", xmPanedWindowWidgetClass, dialog,
  996.         XmNsashWidth,  1,
  997.         XmNsashHeight, 1,
  998.         NULL);
  999.  
  1000.     /* create the control area (Form) which contains a
  1001.      * Label gadget and a List widget.
  1002.      */
  1003.     rc = XtVaCreateWidget("control_area", xmRowColumnWidgetClass, pane, NULL);
  1004.     string = XmStringCreateSimple("Type Something:");
  1005.     XtVaCreateManagedWidget("label", xmLabelGadgetClass, rc,
  1006.         XmNlabelString,    string,
  1007.         XmNleftAttachment, XmATTACH_FORM,
  1008.         XmNtopAttachment,  XmATTACH_FORM,
  1009.         NULL);
  1010.     XmStringFree(string);
  1011.  
  1012.     text_w = XtVaCreateManagedWidget("text-field",
  1013.         xmTextFieldWidgetClass, rc, NULL);
  1014.  
  1015.     /* RowColumn is full -- now manage */
  1016.     XtManageChild(rc);
  1017.  
  1018.     /* Set the client data "Ok" and "Cancel" button's callbacks. */
  1019.     action_items[0].data = (caddr_t)text_w;
  1020.     action_items[1].data = (caddr_t)text_w;
  1021.  
  1022.     /* Create the action area -- we don't need the widget it returns. */
  1023.     action_a = CreateActionArea(pane, action_items, XtNumber(action_items));
  1024.  
  1025.     /* callback for Return in TextField.  Use action_a as client data */
  1026.     XtAddCallback(text_w, XmNactivateCallback, activate_cb, action_a);
  1027.  
  1028.     XtManageChild(pane);
  1029.     XtPopup(dialog, XtGrabNone);
  1030. }
  1031.  
  1032. /*--------------*/
  1033. /* The next four functions are the callback routines for the buttons
  1034.  * in the action area for the dialog created above.  Again, they are
  1035.  * simple examples, yet they demonstrate the fundamental design approach.
  1036.  */
  1037. static void
  1038. close_dialog(w, shell)
  1039. Widget w, shell;
  1040. {
  1041.     XtDestroyWidget(shell);
  1042. }
  1043.  
  1044. /* The "ok" button was pushed or the user pressed Return */
  1045. static void
  1046. ok_pushed(w, text_w, cbs)
  1047. Widget w, text_w;         /* the text widget is the client data */
  1048. XmAnyCallbackStruct *cbs;
  1049. {
  1050.     char *text = XmTextFieldGetString(text_w);
  1051.  
  1052.     printf("String = %s0, text);
  1053.     XtFree(text);
  1054. }
  1055.  
  1056. static void
  1057. cancel_pushed(w, text_w, cbs)
  1058. Widget w, text_w;         /* the text field is the client data */
  1059. XmAnyCallbackStruct *cbs;
  1060. {
  1061.     /* cancel the whole operation; reset to NULL. */
  1062.     XmTextFieldSetString(text_w, "");
  1063. }
  1064.  
  1065. static void
  1066. help(w, string)
  1067. Widget w;
  1068. String string;
  1069. {
  1070.     puts(string);
  1071. }
  1072. /*--------------*/
  1073.  
  1074. /* When Return is pressed in TextField widget, respond by getting
  1075.  * the designated "default button" in the action area and activate
  1076.  * it as if the user had selected it.
  1077.  */
  1078. static void
  1079. activate_cb(text_w, client_data, cbs)
  1080. Widget text_w;              /* user pressed Return in this widget */
  1081. XtPointer client_data;        /* action_area passed as client data */
  1082. XmAnyCallbackStruct *cbs;   /* borrow the "event" field from this */
  1083. {
  1084.     Widget dflt, action_area = (Widget)client_data;
  1085.  
  1086.     XtVaGetValues(action_area, XmNdefaultButton, &dflt, NULL);
  1087.     if (dflt) /* sanity check -- this better work */
  1088.         /* make the default button think it got pushed.  This causes
  1089.          * "ok_pushed" to be called, but XtCallActionProc() causes
  1090.          * the button appear to be activated as if the user selected it.
  1091.          */
  1092.         XtCallActionProc(dflt, "ArmAndActivate", cbs->event, NULL, 0);
  1093. }
  1094.  
  1095. #define TIGHTNESS 20
  1096.  
  1097. Widget
  1098. CreateActionArea(parent, actions, num_actions)
  1099. Widget parent;
  1100. ActionAreaItem *actions;
  1101. int num_actions;
  1102. {
  1103.     Widget action_area, widget;
  1104.     int i;
  1105.  
  1106.     action_area = XtVaCreateWidget("action_area", xmFormWidgetClass, parent,
  1107.         XmNfractionBase, TIGHTNESS*num_actions - 1,
  1108.         XmNleftOffset,   10,
  1109.         XmNrightOffset,  10,
  1110.         NULL);
  1111.  
  1112.     for (i = 0; i < num_actions; i++) {
  1113.         widget = XtVaCreateManagedWidget(actions[i].label,
  1114.             xmPushButtonWidgetClass, action_area,
  1115.             XmNleftAttachment,       i? XmATTACH_POSITION : XmATTACH_FORM,
  1116.             XmNleftPosition,         TIGHTNESS*i,
  1117.             XmNtopAttachment,        XmATTACH_FORM,
  1118.             XmNbottomAttachment,     XmATTACH_FORM,
  1119.             XmNrightAttachment,
  1120.                     i != num_actions-1? XmATTACH_POSITION : XmATTACH_FORM,
  1121.             XmNrightPosition,        TIGHTNESS*i + (TIGHTNESS-1),
  1122.             XmNshowAsDefault,        i == 0,
  1123.             XmNdefaultButtonShadowThickness, 1,
  1124.             NULL);
  1125.         if (actions[i].callback)
  1126.             XtAddCallback(widget, XmNactivateCallback,
  1127.                 actions[i].callback, actions[i].data);
  1128.         if (i == 0) {
  1129.             /* Set the action_area's default button to the first widget
  1130.              * created (or, make the index a parameter to the function
  1131.              * or have it be part of the data structure). Also, set the
  1132.              * pane window constraint for max and min heights so this
  1133.              * particular pane in the PanedWindow is not resizable.
  1134.              */
  1135.             Dimension height, h;
  1136.             XtVaGetValues(action_area, XmNmarginHeight, &h, NULL);
  1137.             XtVaGetValues(widget, XmNheight, &height, NULL);
  1138.             height += 2 * h;
  1139.             XtVaSetValues(action_area,
  1140.                 XmNdefaultButton, widget,
  1141.                 XmNpaneMaximum,   height,
  1142.                 XmNpaneMinimum,   height,
  1143.                 NULL);
  1144.         }
  1145.     }
  1146.  
  1147.     XtManageChild(action_area);
  1148.  
  1149.     return action_area;
  1150. }
  1151.  
  1152.  
  1153.  
  1154. -----------------------------------------------------------------------------
  1155. Subject: 145)  How do I create a "busy working cursor"?
  1156.  
  1157. Answer: - in Baudouin's code (following), the idea is to keep in an array an
  1158. up-to-date list of all shells used in the application, and set for all of them
  1159. the cursor to a watch or to the default cursor, with the 2 functions provided.
  1160.  
  1161. - in Dan Heller's code (later), the idea is to turn on the watch cursor for
  1162. the top-level shell only, popup a working window to possibly abort the
  1163. callback, and manage some expose events during the callback.
  1164.  
  1165. - in the FAQ for comp.windows.x (#113), the idea is to bring a large window on
  1166. top of the application, hide all windows below it, and turn on the watch
  1167. cursor on this large window. Unmapping the large window resets the default
  1168. cursor, mapping it turns on the watch cursor.
  1169.  
  1170. From Baudouin Raoult (mab@ecmwf.co.uk)
  1171.  
  1172. void my_SetWatchCursor(w)
  1173. Widget w;
  1174. {
  1175.         static Cursor watch = NULL;
  1176.  
  1177.         if(!watch)
  1178.                 watch = XCreateFontCursor(XtDisplay(w),XC_watch);
  1179.  
  1180.         XDefineCursor(XtDisplay(w),XtWindow(w),watch);
  1181.         XmUpdateDisplay(w);
  1182. }
  1183.  
  1184. void my_ResetCursor(w)
  1185. Widget w;
  1186. {
  1187.         XUndefineCursor(XtDisplay(w),XtWindow(w));
  1188.         XmUpdateDisplay(w);
  1189. }
  1190.  
  1191.  
  1192. Answer: A solution with lots of bells and whistles is
  1193. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  1194.  * This program is freely distributable without licensing fees and
  1195.  * is provided without guarantee or warrantee expressed or implied.
  1196.  * This program is -not- in the public domain.
  1197.  */
  1198.  
  1199. /* busy.c -- demonstrate how to use a WorkingDialog and to process
  1200.  * only "important" events.  e.g., those that may interrupt the
  1201.  * task or to repaint widgets for exposure.  Set up a simple shell
  1202.  * and a widget that, when pressed, immediately goes into its own
  1203.  * loop.  First, "lock" the shell so that a timeout cursor is set on
  1204.  * the shell and pop up a WorkingDialog.  Then enter loop ... sleep
  1205.  * for one second ten times, checking between each interval to see
  1206.  * if the user clicked the Stop button or if any widgets need to be
  1207.  * refreshed.  Ignore all other events.
  1208.  *
  1209.  * main() and get_busy() are stubs that would be replaced by a real
  1210.  * application; all other functions can be used "as is."
  1211.  */
  1212. #include <Xm/MessageB.h>
  1213. #include <Xm/PushB.h>
  1214. #include <X11/cursorfont.h>
  1215.  
  1216. Widget shell;
  1217. void TimeoutCursors();
  1218. Boolean CheckForInterrupt();
  1219.  
  1220. main(argc, argv)
  1221. int argc;
  1222. char *argv[];
  1223. {
  1224.     XtAppContext app;
  1225.     Widget button;
  1226.     XmString label;
  1227.     void get_busy();
  1228.  
  1229.     shell = XtVaAppInitialize(&app, "Demos",
  1230.         NULL, 0, &argc, argv, NULL, NULL);
  1231.  
  1232.     label = XmStringCreateSimple(
  1233.         "Boy, is *this* going to take a long time.");
  1234.     button = XtVaCreateManagedWidget("button",
  1235.         xmPushButtonWidgetClass, shell,
  1236.         XmNlabelString,          label,
  1237.         NULL);
  1238.     XmStringFree(label);
  1239.     XtAddCallback(button, XmNactivateCallback, get_busy, argv[1]);
  1240.  
  1241.     XtRealizeWidget(shell);
  1242.     XtAppMainLoop(app);
  1243. }
  1244.  
  1245. void
  1246. get_busy(widget)
  1247. Widget widget;
  1248. {
  1249.     int n;
  1250.  
  1251.     TimeoutCursors(True, True);
  1252.     for (n = 0; n < 10; n++) {
  1253.         sleep(1);
  1254.         if (CheckForInterrupt()) {
  1255.             puts("Interrupt!");
  1256.             break;
  1257.         }
  1258.     }
  1259.     if (n == 10)
  1260.         puts("done.");
  1261.     TimeoutCursors(False, NULL);
  1262. }
  1263.  
  1264. /* The interesting part of the program -- extract and use at will */
  1265. static Boolean stopped;  /* True when user wants to stop processing */
  1266. static Widget dialog;    /* WorkingDialog displayed when timed out */
  1267.  
  1268. /* timeout_cursors() turns on the "watch" cursor over the application
  1269.  * to provide feedback for the user that he's going to be waiting
  1270.  * a while before he can interact with the appliation again.
  1271.  */
  1272. void
  1273. TimeoutCursors(on, interruptable)
  1274. int on, interruptable;
  1275. {
  1276.     static int locked;
  1277.     static Cursor cursor;
  1278.     extern Widget shell;
  1279.     XSetWindowAttributes attrs;
  1280.     Display *dpy = XtDisplay(shell);
  1281.     XEvent event;
  1282.     Arg args[1];
  1283.     XmString str;
  1284.     extern void stop();
  1285.  
  1286.     /* "locked" keeps track if we've already called the function.
  1287.      * This allows recursion and is necessary for most situations.
  1288.      */
  1289.     on? locked++ : locked--;
  1290.     if (locked > 1 || locked == 1 && on == 0)
  1291.         return; /* already locked and we're not unlocking */
  1292.  
  1293.     stopped = False; /* doesn't matter at this point; initialize */
  1294.     if (!cursor) /* make sure the timeout cursor is initialized */
  1295.         cursor = XCreateFontCursor(dpy, XC_watch);
  1296.  
  1297.     /* if "on" is true, then turn on watch cursor, otherwise, return
  1298.      * the shell's cursor to normal.
  1299.      */
  1300.     attrs.cursor = on? cursor : None;
  1301.  
  1302.     /* change the main application shell's cursor to be the timeout
  1303.      * cursor (or to reset it to normal).  If other shells exist in
  1304.      * this application, they will have to be listed here in order
  1305.      * for them to have timeout cursors too.
  1306.      */
  1307.     XChangeWindowAttributes(dpy, XtWindow(shell), CWCursor, &attrs);
  1308.  
  1309.     XFlush(dpy);
  1310.  
  1311.     if (on) {
  1312.         /* we're timing out, put up a WorkingDialog.  If the process
  1313.          * is interruptable, allow a "Stop" button.  Otherwise, remove
  1314.          * all actions so the user can't stop the processing.
  1315.          */
  1316.         str = XmStringCreateSimple("Busy.  Please Wait.");
  1317.         XtSetArg(args[0], XmNmessageString, str);
  1318.         dialog = XmCreateWorkingDialog(shell, "Busy", args, 1);
  1319.         XmStringFree(str);
  1320.         XtUnmanageChild(
  1321.             XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON));
  1322.         if (interruptable) {
  1323.             str = XmStringCreateSimple("Stop");
  1324.             XtVaSetValues(dialog, XmNcancelLabelString, str, NULL);
  1325.             XmStringFree(str);
  1326.             XtAddCallback(dialog, XmNcancelCallback, stop, NULL);
  1327.         } else
  1328.             XtUnmanageChild(
  1329.                 XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
  1330.         XtUnmanageChild(
  1331.             XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
  1332.         XtManageChild(dialog);
  1333.     } else {
  1334.         /* get rid of all button and keyboard events that occured
  1335.          * during the time out.  The user shouldn't have done anything
  1336.          * during this time, so flush for button and keypress events.
  1337.          * KeyRelease events are not discarded because accelerators
  1338.          * require the corresponding release event before normal input
  1339.          * can continue.
  1340.          */
  1341.         while (XCheckMaskEvent(dpy,
  1342.                 ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
  1343.                 | PointerMotionMask | KeyPressMask, &event)) {
  1344.             /* do nothing */;
  1345.         }
  1346.         XtDestroyWidget(dialog);
  1347.     }
  1348. }
  1349.  
  1350. /* User Pressed the "Stop" button in dialog. */
  1351. void
  1352. stop(dialog)
  1353. Widget dialog;
  1354. {
  1355.     stopped = True;
  1356. }
  1357.  
  1358. Boolean
  1359. CheckForInterrupt()
  1360. {
  1361.     extern Widget shell;
  1362.     Display *dpy = XtDisplay(shell);
  1363.     Window win = XtWindow(dialog);
  1364.     XEvent event;
  1365.  
  1366.     /* Make sure all our requests get to the server */
  1367.     XFlush(dpy);
  1368.  
  1369.     /* Let motif process all pending exposure events for us. */
  1370.     XmUpdateDisplay(shell);
  1371.  
  1372.     /* Check the event loop for events in the dialog ("Stop"?) */
  1373.     while (XCheckMaskEvent(dpy,
  1374.             ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
  1375.             PointerMotionMask | KeyPressMask | KeyReleaseMask,
  1376.             &event)) {
  1377.         /* got an "interesting" event. */
  1378.         if (event.xany.window == win)
  1379.             XtDispatchEvent(&event); /* it's in our dialog.. */
  1380.         else /* uninteresting event--throw it away and sound bell */
  1381.             XBell(dpy, 50);
  1382.     }
  1383.     return stopped;
  1384. }
  1385.  
  1386.  
  1387. -----------------------------------------------------------------------------
  1388. Subject: 146)  Can I use the hourglass that mwm uses?
  1389.  
  1390. [Last modified: March 93]
  1391.  
  1392. Answer: The hourglass used by mwm is hard-coded into code that is subject to
  1393. OSF copyright. In Motif 1.2 though, the bitmaps for this and other things
  1394. (information, no_enter, question, warning, working) were made available.  The
  1395. install process will probably add them to /usr/include/X11/bitmaps.
  1396. Otherwise, just use the watch cursor XC_watch of the previous question,
  1397. because that has the same semantics.
  1398.  
  1399.  
  1400.  
  1401. -----------------------------------------------------------------------------
  1402. Subject: 147)  What order should the libraries be linked in?
  1403.  
  1404. [Last modified: August 92]
  1405.  
  1406. Answer: At link time, use the library order  -lXm -lXt -lX11. There are two
  1407. reasons for this (dbrooks@osf.org):
  1408.  
  1409. On most systems, the order matters because the linker won't re-scan a library
  1410. once it is done with it.  Thus any references to Xlib calls from Xm will
  1411. probably be unresolved.
  1412.  
  1413. The [other] problem is that there are two VendorShell widgets. A dummy is
  1414. provided in the Xt library, but a widget set will rely on its own being
  1415. referenced.  If you mention Xt first, the linker will choose the wrong one.
  1416.  
  1417. Motif code will wrongly assume the Motif VendorShell has been class-
  1418. initialized [and will probably crash].
  1419.  Xaw has a similar problem, but a softer landing; it only complains about
  1420. unregistered converters.
  1421.  
  1422.  
  1423. -----------------------------------------------------------------------------
  1424. Subject: 148)  How do I use xmkmf for Motif clients?
  1425.  
  1426. [Last modified: October 1992]
  1427.  
  1428. Answer: This advice comes from dbrooks@osf.org:
  1429.  
  1430. There are a number of intractable problems with using X configuration files
  1431. and xmkmf, while trying to make it easy to build Motif.  Not the least of
  1432. these, but one I've never heard mentioned yet, is that the rules for
  1433. contructing the names of shared library macros are machine-dependent, and in
  1434. the various xxxLib.tmpl files.  Do we edit all those files to add definitions
  1435. for XMLIB, DEPXMLIB, etc., or do we put a maze of #ifdefs into the Motif.tmpl
  1436. file?
  1437.  
  1438. Please note that, if you install Motif, it overwrites your installed
  1439. Imake.tmpl with one that includes Motif.tmpl and Motif.rules.
  1440.  
  1441. With those caveats, I think the following guidelines will help.
  1442.  
  1443. David Brooks OSF
  1444.  
  1445. Clients in the X11R5 release use the xmkmf command to build Makefiles.  In
  1446. general, the xmkmf command cannot be used for Motif clients, because of the
  1447. need to consider the UseInstalledMotif flag separately.  Since xmkmf is a
  1448. simple script that calls imake, it is easy to construct the proper call to
  1449. imake using the following rules.
  1450.  
  1451. In the following, replace {MTOP} by the toplevel directory with the Motif
  1452. source tree, and {XTOP} by the toplevel ("mit") directory with the X source.
  1453. It is assumed that the directory containing your installed imake is in your
  1454. PATH.
  1455.  
  1456. When needed, the imake variables XTop and MTop are normally set in your
  1457. site.def (to {XTOP} amd {MTOP} respectively); however they may also be set
  1458. with additional -D arguments to imake.
  1459.  
  1460. 1. With both X and Motif in their source trees, ensure the imake variables
  1461.    XTop and MTop are set, and use:
  1462.  
  1463.         ${XTOP}/config/imake -I{MTOP}/config
  1464.  
  1465. 2. With Motif in its source tree, and X installed, ensure MTop is set, and
  1466.    use:
  1467.  
  1468.         imake -I{MTOP}/config -DUseInstalled
  1469.  
  1470. 3. With both Motif and X installed, and a nonstandard ProjectRoot (see
  1471.    site.def for an explanation of this), use:
  1472.  
  1473.         imake -DUseInstalled -DUseInstalledMotif -I{ProjectRoot}/lib/X11/config
  1474.  
  1475.    or, if the configuration files are in /usr/lib/X11/config:
  1476.  
  1477.         imake -DUseInstalled -DUseInstalledMotif
  1478.  
  1479.  
  1480. To build a simple Imakefile, remember to include lines like this:
  1481.  
  1482.         LOCAL_LIBRARIES = XmClientLibs
  1483.                 DEPLIBS = XmClientDepLibs
  1484.  
  1485. Or, for a client that uses uil/mrm, replace these by MrmClientLibs and
  1486. MrmClientDepLibs, and also use:
  1487.  
  1488.         MSimpleUilTarget(program)
  1489.  
  1490. to build the client and uid file.  Look at the demos for more examples.
  1491.  
  1492.  
  1493. And Paul Howell <grue@engin.umich.edu> added:
  1494.  
  1495. i did this, calling the new script "xmmkmf".  It passes both -DUseInstalled
  1496. and -DUseInstalledMotif.
  1497.  
  1498. and i modified the stock R5 Imake.tmpl to do this:
  1499.  
  1500. #include <Project.tmpl>
  1501. #ifdef UseInstalledMotif
  1502. #include <Motif.tmpl>
  1503. #endif
  1504.  
  1505. #include <Imake.rules>
  1506. #ifdef UseInstalledMotif
  1507. #include <Motif.rules>
  1508. #endif
  1509.  
  1510. the result was something that does both athena and motif rules.  and it really
  1511. works, just that easy!
  1512.  
  1513.  
  1514. -----------------------------------------------------------------------------
  1515. Subject: 149)  How do I make context sensitive help?  The Motif Style Guide
  1516. says that an application must initiate context-sensitive help by changing the
  1517. shape of the pointer to the question pointer. When the user moves the pointer
  1518. to the component help is wanted on and presses BSelect, any available context
  1519. sensitive help for the component must be presented, and the pointer reverts
  1520. from the question pointer.
  1521. [Last modified: August 92]
  1522.  
  1523. Answer: A widget that gives context sensitive help would place this help in
  1524. the XmNhelpCallback function. To trigger this function: (from Martin G C
  1525. Davies, mgcd@se.alcbel.be)
  1526.  
  1527. I use the following callback that is called when the "On Context" help
  1528. pulldown menu is selected. It does the arrow bit and calls the help callbacks
  1529. for the widget. It also zips up the widget tree looking for help if needs be.
  1530. I don't restrict the arrows motion so I can get help on dialog boxes. No
  1531. prizes for guessing what "popup_message" does.
  1532.  
  1533.  
  1534. static void ContextHelp(
  1535.     Widget              w ,
  1536.     Opaque              * tag ,
  1537.     XmAnyCallbackStruct * callback_struct
  1538. )
  1539. {
  1540.     static Cursor   context_cursor = NULL ;
  1541.     Widget          context_widget ;
  1542.  
  1543.     if ( context_cursor == NULL )
  1544.         context_cursor = XCreateFontCursor( display, XC_question_arrow ) ;
  1545.  
  1546.     context_widget = XmTrackingLocate( top_level_widget,
  1547.                                 context_cursor, FALSE ) ;
  1548.  
  1549.     if ( context_widget != NULL ) /* otherwise its not a widget */
  1550.     {
  1551.         XmAnyCallbackStruct cb ;
  1552.  
  1553.         cb.reason = XmCR_HELP ;
  1554.         cb.event = callback_struct->event ;
  1555.  
  1556.         /*
  1557.          * If there's no help at this widget we'll track back
  1558.            up the hierarchy trying to find some.
  1559.          */
  1560.  
  1561.         do
  1562.         {
  1563.             if ( ( XtHasCallbacks( context_widget, XmNhelpCallback ) ==
  1564.                                                 XtCallbackHasSome ) )
  1565.             {
  1566.                 XtCallCallbacks( context_widget, XmNhelpCallback, & cb ) ;
  1567.                 return ;
  1568.             }
  1569.             else
  1570.                 context_widget = XtParent( context_widget ) ;
  1571.         } while ( context_widget != NULL ) ;
  1572.     }
  1573.  
  1574.     popup_message( "No context-sensitive help found\n\
  1575. for the selected object." ) ;
  1576. }
  1577.  
  1578.  
  1579.  
  1580. Dave Bonnett suggested, to use the following translations for XmText (and
  1581. XmTextField) widgets to get the same help with key strokes, and to provide an
  1582. accelerator label in the Context help menu entry.
  1583.  
  1584. MyApp*XmText*translations: #override\n\
  1585.                                 <Key>F1:    Help()
  1586.  
  1587. MyApp*Help_menu*Contextual Help.acceleratorText:   F1
  1588.  
  1589. MyApp*defaultVirtualBindings:           osfBackSpace : <Key>Delete\n\
  1590.                                         osfRight : <Key>Right\n\
  1591.                                         osfLeft  : <Key>Left\n\
  1592.                                         osfUp    : <Key>Up\n\
  1593.                                         osfHelp  : <Key>F1\n\
  1594.                                         osfDown  : <Key>Down
  1595.  
  1596.  
  1597. -----------------------------------------------------------------------------
  1598. Subject: 150)  How do I debug a modal interaction?
  1599.  
  1600. When an application crashes in a modal section (such as in a modal dialog, a
  1601. menu or when a drag and drop is in action), I cannot access the debugger.
  1602.  
  1603. [Last modified: January 1993]
  1604.  
  1605. Answer: Run the debugger on one display while the application writes to
  1606. another display.
  1607.  
  1608.  
  1609. -----------------------------------------------------------------------------
  1610. Subject: 151)  Where can I get info on the Motif drag and drop protocol?
  1611.  
  1612. [Last modified: March]
  1613.  
  1614. Answer: The drag and drop protocol implemented by OSF is not stable, so they
  1615. have not published it yet. The API should remain stable though.  The OSF
  1616. protocol is not compatable with the OpenLook protocol.  OSF and Sun are
  1617. working on a joint protocol for publication.
  1618.  
  1619. For programming examples on Motif D&D, see the Motif 1.2 Programmers Guide.
  1620.  
  1621. For a third alternative, try Roger Reynolds D&D protocol, available from
  1622. netcom.com in /pub/rogerr.
  1623.  
  1624. -----------------------------------------------------------------------------
  1625. Subject: 152) TOPIC: ACKNOWLEDGEMENTS
  1626.  
  1627. This list was compiled using questions and answers posed to
  1628. comp.windows.x.motif and motif-talk. Some extracts were also taken from FAQs
  1629. of comp.windows.x.  To all who contributed one way or the other, thanks! I
  1630. haven't often given individual references, but  you may recognise
  1631. contributions. If I have mangled them too much, let me know.
  1632.  
  1633.  
  1634.  
  1635. That's all folks!
  1636.  
  1637.  
  1638. +----------------------+---+
  1639.   Jan Newmarch, Information Science and Engineering,
  1640.   University of Canberra, PO Box 1, Belconnen, Act 2616
  1641.   Australia. Tel: (Aust) 6-2522422. Fax: (Aust) 6-2522999
  1642.  
  1643.   ACSnet: jan@ise.canberra.edu.au
  1644.   ARPA:   jan%ise.canberra.edu.au@uunet.uu.net
  1645.   UUCP:   {uunet,ukc}!munnari!ise.canberra.edu.au!jan
  1646.   JANET:  jan%au.edu.canberra.ise@EAN-RELAY
  1647.  
  1648. +--------------------------+
  1649. --
  1650. +----------------------+---+
  1651.   Jan Newmarch, Information Science and Engineering,
  1652.   University of Canberra, PO Box 1, Belconnen, Act 2616
  1653.   Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
  1654.